<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<jsp:include page="../../ueditor.jsp"></jsp:include>
<%@page import="com.sdry.entity.base.Staff"%>
<%
	String path=request.getContextPath();
%>
<!DOCTYPE html>
<html lang="zh">
<head>
	<style>
		table.table-edit tr td{
			text-align:center;
			vertical-align:middle;
			font-size: 20px;
		}
		table.table-edit tr{border-bottom:1px white solid;}
		table.table-edit tr.title {
			background-color: #EAEAEA4D;
		}
		table.table-edit tr.title td{
			font-size: 30px;
		}
		/*初始化编辑器高度,默认320*/
        #edui1_iframeholder{
            height: 70vh !important
        }
		/*input边框样式*/
		/*input{
			/*//设置输入框中字体的大小*/
			font-size:17px;
			/*//设置输入框的高度*/
			height:30px;
			/*//设置输入框的圆角的大小*/
			border-radius:10px;
			/*//设置输入框边框的粗细和颜色*/
			border:1px solid #c8cccf;
			/*//设置输入框中文字的颜色*/
			color:#986655;
			/*//将输入框点击的时候出现的边框去掉*/
			outline:0;
			/*//设置输入框中文字的位置*/
			text-align:center;
			/*//将输入框设置为块级元素*/
			/*//display:block;*/
		}*/
		/*边框颜色*/
		input[type="text"], input[type="password"], textarea {
			border: 1px solid #DEE4EA99;
		}
		/*去掉点击是出现的验证红框*/
		.focus, input:focus, select:focus, textarea:focus {
			outline: 1px solid #f000;
		}
	</style>
</head>
<body style="background-color: #ffffff;">
<div class="page-content-iframe">
	<div region="center">
		<form id="fm">
			<input type="hidden" id="contentID" name="contentID" value="${content.contentID }">
			<input type="hidden" id="staffID" name="staffID" value="${content.staffID }">
			<table class="table-edit" width="100%" align="center">
				<tr class="title">
					<td colspan="5">
						我的文档
						<div style="width: 200px;margin-top: -33px;margin-left: 80%;margin-right: 0px;">
							<a icon="icon-back" class="easyui-linkbutton" plain="true" onclick="history.go(-1)">返回</a>
							&nbsp;&nbsp;
							<a icon="icon-save" class="easyui-linkbutton" plain="true" onclick="save()">保存</a>
							&nbsp;&nbsp;&nbsp;
						</div>
					</td>
				</tr>
				<tr></tr>
				<tr>
					<td colspan="5">
						文档类别:
						<select id="reserved1" name="reserved1"  class="easyui-combobox" data-options="required:true" editable="false" style="width: 156px;">
						</select>
						<script type="text/javascript">
							$(function(){
								$.ajax({
						            url: '/type/selectAll.do' ,
						            type: 'post',
						            async:false,
						            dataType:'json',
						            success: function (data) {
						            	 var datas = [];
						                //设置下拉列表中的值的属性
						                for ( var i = 0; i < data.length; i++) {
						              	  	datas.push({"text":data[i].tname,"value":data[i].id});
										 }
						                $("#reserved1").combobox("loadData",datas);////此时我们便将所有option添加到select中了
						                var reserved1 = '${content.reserved1}';
										if(reserved1 != "" && reserved1 != null){
											$("#reserved1").combobox("setValue",reserved1);
										}
						            },
						        });
					        });
							
						</script>
						&nbsp;&nbsp;&nbsp;标题:
						<!-- ,validType:['aname','length[20,2000]'] -->
						<textarea type="text" id="title" name="title"  placeholder="请输入标题" class="easyui-validatebox"  data-options="required:true" validType="aname" style="width: 674px;height: 20px">${content.title }</textarea>
					</td> 
				</tr>
				<tr>
					<td colspan="5" style="text-align:left: ;">
						<textarea id="content" name="content">${content.content }</textarea>
					</td>
				</tr>
			</table>
		</form>
	</div>
</div>
<script type="text/javascript">
	var ue = UE.getEditor('content');
	//是否执行保存操作标识
	var addFlg = true;
	//保存
    function save() {
        if (addFlg == false) {
            return false;
        }else{
	        addFlg = false;
        }
        if ($("#fm").form("validate")==false) {
        	addFlg = true;
            return false;
        }
        var content = ue.getContentTxt();
        if (content == '') {
        	toastr.warning('内容不能为空!');
        	addFlg = true;
        	return false;
		}
        var contentID = $('#contentID').val();
        if (contentID == '') {
			var title="新增";
    	} else {
			var title="修改";
    	}
        $.ajax({
			url : '${pageContext.request.contextPath }/contentMana/saveContent.do',
			data : $('#fm').serialize(),
			type : "post",
			async: false,  
			dataType : "json",
			success : function(data) {
				if (data == 1) {
					toastr.success(title+'成功');
					setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
						window.history.go(-1);
					addFlg = true;
					},1000);
				} else {
					toastr.error(title+'失败，请重新操作');
					addFlg = true;
				}
			},
			error : function () {
				toastr.error(title+'失败！');
				addFlg  =  true
			}
        })
	}
    
    function go() {
        window.history.go(-1);
    }

</script>
</body>
</html>
